require(['./config'],() => {
	require(['swiper','template',"request",'header','footer'],(Swiper,template,req)=>{
		class Index{
			constructor() {
			    this.init()
				this.slide()
				this.getIndexSlide()
			}
			init(){
				//初始化swiper
				var myswiper = new Swiper('.swiper-container', {
					 loop:true,
				     autoplay: {
				       delay: 2500,
				       disableOnInteraction: false,
				     },
				     pagination: {
				       el: '.swiper-pagination',
				       clickable: true,
				     },
				     navigation: {
				       nextEl: '.swiper-button-next',
				       prevEl: '.swiper-button-prev',
				     },
				});
			}
			slide(){
				var swiper2 = new Swiper('.swiper-container2', {
				     slidesPerView: 6,
				     spaceBetween: 12,
				     slidesPerGroup: 6,
				     loop: true,
				     pagination: {
				       el: '.swiper-pagination2',
				       clickable: true,
				     },
				     navigation: {
				       nextEl: '.swiper-button-next',
				       prevEl: '.swiper-button-prev',
				     },
				 });				
			}
			// 获取滑动
			getIndexSlide(){
				req.getIndexSlideList().then(res => {
					if(res.code === 200){
						const {Data2,data} = res
						const html = template('indexSlideTemplate',{data})
						$('.slide').html(html)						
						this.getIndexData(Data2)
						// console.log(res)
						console.log(data)
					}
				})
			}
			// 获取界面
			getIndexData(prodList){
				$('.jiemian').html(template('indexDataTemplate',{prodList}))
				console.log(prodList)
			}
			
		}
		return new Index();
	})
})